package com.study.jdbc.junit;

import java.sql.Connection;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

import org.junit.Test;

public class GetConnectionTest {
	
	@Test
	public void getConnection() throws Exception {
		Context initCtx = new InitialContext();
		Context envCtx = (Context) initCtx.lookup("java:comp/env");
		DataSource ds = (DataSource) envCtx.lookup("jdbc/tomcat-datasource");
		Connection conn = ds.getConnection();
		System.out.println(conn.getClass().getName());
	}


}
